package slash.client.swing.controls;

import javax.swing.*;

import slash.client.controllers.ChatListener;
import slash.client.controllers.GameController;

import java.awt.BorderLayout;
import java.awt.TextArea;

/**
 * @author gsh
 */
public class ControlPanel extends JPanel implements ChatListener {
	private TextArea textArea;
	
	public void chat(String msg) {
		if (textArea != null) {
			textArea.append(msg+"\n");
		}
	}
	
	public ControlPanel() {
		addComponents();
	}

	private void addComponents() {
		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		JButton newGameButton = new JButton("New Game");
		add(newGameButton, BorderLayout.NORTH);

		textArea = new TextArea("Event Log:\n", 10, 30);
		add(textArea, BorderLayout.SOUTH);
		textArea.setFocusable(false);
		textArea.enableInputMethods(false);
		
		GameController.get().addChatListener(this);
	}
}
